package com.studentachievement.dao;

import com.studentachievement.beans.Admin;
import com.studentachievement.beans.Course;
import com.studentachievement.beans.Score;
import com.studentachievement.beans.Student;
import com.studentachievement.utils.DatabaseUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
//        Student student = new Student();
//        student = StudentDAO.getStudentByUsernameAndPassword("张三","123456");
//        student.print();
//        List<Score> scores = null;
//        scores = StudentDAO.getStudentScores(1);
//        for (Score score : scores) {
//            System.out.print(score + ":  ");
//            score.print();
//        }
//        StudentDAO.aStudent();

        Admin admin = new Admin();
        admin = AdminDAO.getAdminByUsernameAndPassword("admin","admin");
        if(admin != null){
            admin.print();
        }else{
            System.out.printf("没找到这个admin");
        }
//        System.out.println("这是分数@");
//        List<Score> scores1 = null;
//        scores1 = AdminDAO.getAllScores();
//        for (Score score : scores1) {
//            score.print();
//        }
//        System.out.println("这是课程@");
//        List<Course> courses = null;
//        courses = AdminDAO.getAllCourses();
//        if(courses == null){
//            System.out.println("coures = NULL");
//        }
//        for (Course course : courses) {
//            course.print();
//        }
//        System.out.println("这是学生@");
//        List<Student> students = null;
//        students = AdminDAO.getAllStudents();
//        for (Student stu : students) {
//            stu.print();
//        }
        System.out.println("搜索=================================================");
//        Student student = AdminDAO.getStudentById(1);
//        if(student != null){
//            student.print();
//        }
//        Course course = AdminDAO.getCourseById(1);
//        if(course != null){
//            course.print();
//        }
//        Score score = AdminDAO.getScoreByStudentIdAndCourseId(1,1);
//        if(score != null){
//            score.print();
//        }
        System.out.println("修改=================================================");
//        student.setName("张三");
//        AdminDAO.updateStudent("张三封",1,student);
//        course.setCredits(4);
//        AdminDAO.updateCourse("高等数学",1,course);
//        score.setScore(66.66);
//        AdminDAO.updateScore(1,1,score);
        System.out.println("添加=================================================");
//        Student student = new Student();
//        student.setName("测试");
//        student.setPassword("123456");
//        student.setGender("女");
//        student.setStudentId(10086);
//        student.setMajor("测试");
//        student.setBirthDate("2024-06-06");
//        AdminDAO.addStudent(student);
//        Course course = new Course();
//        course.setCredits(66);
//        course.setCourseName("测试");
//        course.setCourseId(10086);
//        course.setTeacherName("测试");
//        AdminDAO.addCourse(course);
        Score score = new Score();
        score.setScore(66);
        score.setScoreId(9);
//        score.setCourseName("测试");
        score.setCourseId(1);
        score.setExamDate("2024-06-06");
        score.setStudentId(1);
//        score.setStudentName("测试");
        AdminDAO.addScore(score);
        System.out.println("删除=================================================");
//        AdminDAO.deleteStudent(9);
//        AdminDAO.deleteCourse(10086);
//        AdminDAO.deleteScore(1,1);
    }
}
